package cn.iocoder.yudao.module.biz.dal.mysql.ticket;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.biz.dal.dataobject.ticket.BizTicketDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.biz.controller.admin.ticket.vo.*;

/**
 * 票证管理 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BizTicketMapper extends BaseMapperX<BizTicketDO> {

    default PageResult<BizTicketDO> selectPage(BizTicketPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BizTicketDO>()
                .likeIfPresent(BizTicketDO::getName, reqVO.getName())
                .eqIfPresent(BizTicketDO::getImage, reqVO.getImage())
                .eqIfPresent(BizTicketDO::getAppendix, reqVO.getAppendix())
                .betweenIfPresent(BizTicketDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(BizTicketDO::getDeptId, reqVO.getDeptId())
                .orderByDesc(BizTicketDO::getId));
    }

    default List<BizTicketDO> selectList(BizTicketExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BizTicketDO>()
                .likeIfPresent(BizTicketDO::getName, reqVO.getName())
                .eqIfPresent(BizTicketDO::getImage, reqVO.getImage())
                .eqIfPresent(BizTicketDO::getAppendix, reqVO.getAppendix())
                .betweenIfPresent(BizTicketDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(BizTicketDO::getDeptId, reqVO.getDeptId())
                .orderByDesc(BizTicketDO::getId));
    }

}
